package com.yunxi.module.system.api.tenant;

import com.yunxi.framework.common.pojo.CommonResult;
import com.yunxi.module.system.service.tenant.TenantService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 提供 RESTFul API 接口，给 Feign 调用
 * </p>
 *
 * @author lidy
 * @since 2024-05-25
 */
@RestController
@Validated
public class TenantApiImpl implements TenantApi {

    @Resource
    private TenantService tenantService;

    /**
     * 获得所有租户编号
     *
     * @return 所有租户编号
     */
    @Override
    public CommonResult<List<Long>> getTenantIdList() {
        return CommonResult.success(tenantService.getTenantIdList());
    }

    /**
     * 校验租户是否合法
     *
     * @param tenantId 租户编号
     * @return 校验结果
     */
    @Override
    public CommonResult<Boolean> validTenant(Long tenantId) {
        tenantService.validTenant(tenantId);
        return CommonResult.success(true);
    }
}
